import { NextRequest, NextResponse } from 'next/server';
import { SDWebUILauncher } from '@/lib/launcher';

const launcher = SDWebUILauncher.getInstance();

export async function POST(request: NextRequest) {
  try {
    const { searchParams } = new URL(request.url);
    const force = searchParams.get('force') === 'true';
    
    const result = await launcher.stopSDWebUI(force);
    return NextResponse.json(result);
  } catch (error: any) {
    return NextResponse.json(
      { 
        success: false, 
        error: error.message 
      },
      { status: 500 }
    );
  }
}
